#include<iostream>
#include<bits/stdc++.h>
#define OK 1
using namespace std;

typedef char TElemType;

typedef struct biTNode{
	TElemType data;
	struct biTNode *lchild,*rchild;
}biTNode,*biTree;//定义二叉链表

void creatbiTree(biTree &T)//先序遍历的顺序建立二叉链表 
{
	char ch;
	cin>>ch;
	if(ch=='#') T=NULL;
	else
	{
		T=new biTNode;
		T->data=ch;
		creatbiTree(T->lchild);
		creatbiTree(T->rchild);
	}
}

void preOrderTraverse(biTree T){
	if(T)
	{
		cout<<T->data;
		preOrderTraverse(T->lchild);
		preOrderTraverse(T->rchild);		
	}

}//先序遍历

void inOrderTraverse(biTree T){
	if(T)
	{
		inOrderTraverse(T->lchild);
		cout<<T->data;
		inOrderTraverse(T->rchild);	
	}

}//中序遍历

void postOrderTraverse(biTree T){
	if(T)
	{
		postOrderTraverse(T->lchild);
		postOrderTraverse(T->rchild);
		cout<<T->data;
			
	}

}//后序遍历

int depth(biTree T)
{
	if(T==NULL) return 0;
	else{
		int m=depth(T->lchild);
		int n=depth(T->rchild);
		if(m>n) return(m+1);
		else return(n+1);
	} 
}//计算二叉树的深度

int nodeCount(biTree T)
{
	if(T==NULL) return 0;
	else return nodeCount(T->lchild)+nodeCount(T->rchild)+1;
}//统计二叉树的节点的个数

int main()
{
	biTree T;
	creatbiTree(T);
    cout<<"creatde successfully"<<endl;
    cout<<"preOrderTraverse:"<<endl;
    preOrderTraverse(T);
    cout<<'\t'<<endl;
    cout<<"inOrderTraverse:"<<endl;
	inOrderTraverse(T);
    cout<<'\t'<<endl;
    cout<<"postOrderTraverse:"<<endl;
    postOrderTraverse(T);
    cout<<'\t'<<endl;
	cout<<"depth:"<<depth(T)<<endl;
	cout<<"count:"<<nodeCount(T)<<endl;
	return 0;
}